import { get, post, post_json } from '../../http/axios'
export default {
  namespaced: true,
  state: {
    orders: [],
    // 全部订单数据
    orderList: []
  },
  mutations: {
    refreshOrder(state, orders) {
      state.orders = orders
    },
    GET_orderData(state, allOrderList){
      state.orderList = allOrderList
    }
  },
  actions: {
    // 保存订单
    async SubmitOrder({ commit }, data) {
      // 调用接口完后保存
      let response = await post_json('/app/order/submitOrder', data)
      console.log(response)
      return response
    },
    // 获取所有订单数据
    async orderDataVuex({ commit }, data){
      let res = await get('/order/pageQuery', data)
      commit('GET_orderData', res.data.data.list)
      console.log(res);
    },
  }
}